home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cbibcode.arc
/
GETFTIME.C
< prev
next >
Wrap
Text File
|
1991-08-05
|
1KB
|
41 lines
/* GETFTIME.C --- p. 610*/
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <dos.h>
main()
{
char fname[40], *p_fname;
int filehandle;
struct ftime dtinfo;
unsigned date, time, day, month, year, hour, minute, second;
printf("Enter name of an existing file: ");
p_fname = gets(fname);
/* Open the file using _open */
if((filehandle = _open(p_fname, O_RDONLY)) == -1)
{
printf("Error opening file: %s\n", fname);
exit(0);
}
printf("File %s opened.\n", fname);
/* Get file's dat and time stamp */
getftime(filehandle, &dtinfo);
/* Now extract the time and date infomation */
second = 2 * dtinfo.ft_tsec;
minute = dtinfo.ft_min;
hour = dtinfo.ft_hour;
day = dtinfo.ft_day;
month = dtinfo.ft_month;
/* NOTE: year is reletive to 1980.
* So weare adding 80. */
year = dtinfo.ft_year + 80;
printf("File: %s Date: %d-%d-%d Time: %.2d:%.2d:%.2d\n",
fname, month, day, year, hour, minute, second);
/* Now close the file */
if(_close(filehandle) != 0)
{
printf("Error closing file with _close\n");
exit(0);
}
printf("File %s closed.\n", fname);
}